//图表显示
var echarts_show = {
    el:"",
    init:function(el){
        this.el = el;
        this.getHeight();
        this.terminal_show();
    },
    getHeight:function(){
        $(".widget").css("margin",0);
        var height1 = $(window).height() - $(".widget-head").height() - parseInt($(".widget").css("padding-top")) - parseInt($(".widget").css("padding-bottom")) - 60;
        console.log($(".widget").css("padding"));
        $("#"+this.el+"").height(height1);
    },
    terminal_show:function(){
        var myChart = echarts.init(document.getElementById(this.el));
        var option_pie = null;
        options_pie = {
            title : {
                text: '用户终端类型',
                x:'center',
                textStyle: {
                    color: '#838FA1'
                }
            },
            tooltip : {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c} ({d}%)"
            },
            legend: {
                orient: 'vertical',
                left: 'left',
                data: ['unkown','STB','PC','Android Phone','Android Pad','iOS Phone','iOS Pad','Web'],
                textStyle: {
                    color: '#838FA1'
                }
            },
            color:['#58b1f9','#7fc4fc','#cde2fa','#5dc485','#88d9a0','#b5ebc5','#ffe167','#ffb59b'],
            // color:['#58b1f9','#5dc485','#f2686a','#c7ddf6','#f5c162','#00d2b5','#dda669','#4c9ad5'],
            animate:true,
            series : [
                {
                    name: '终端类型',
                    type: 'pie',
                    radius : '55%',
                    center: ['50%', '60%'],
                    data:[
                        {value:335, name:'unkown'},
                        {value:310, name:'STB'},
                        {value:155, name:'PC'},
                        {value:135, name:'Android Phone'},
                        {value:121, name:'Android Pad'},
                        {value:107, name:'iOS Phone'},
                        {value:77, name:'iOS Pad'},
                        {value:56, name:'Web'}
                    ],
                    itemStyle: {
                        emphasis: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    }
                }
            ]
        };
        myChart.setOption(options_pie, true);
    }
};

// 调用echarts_show
echarts_show.init("terminal-echarts");